<template>
  <div class="modern-list-container">
    <!-- 主内容区域 -->
    <div v-if="showFlag" class="modern-list-content">
      <!-- 工具栏 -->
      <div class="modern-toolbar">
        <!-- 搜索区域 -->
        <div class="modern-search-panel">
          <el-form class="modern-search-form">
            <div class="search-group">
              <el-input
                v-model="searchForm.xiquName"
                placeholder="中医药文化知识名称"
                class="modern-input"
                prefix-icon="el-icon-search"
                clearable
              >
              </el-input>

              <el-select
                v-model="searchForm.xiquTypes"
                placeholder="知识类型"
                class="modern-select"
              >
                <el-option label="全部类型" value=""></el-option>
                <el-option
                  v-for="(item, index) in xiquTypesSelectSearch"
                  :key="index"
                  :label="item.indexName"
                  :value="item.codeIndex"
                ></el-option>
              </el-select>

              <el-button
                type="primary"
                class="modern-search-btn"
                @click="search"
              >
                <i class="el-icon-search"></i>
                查询
              </el-button>
            </div>
          </el-form>
        </div>

        <!-- 操作按钮组 -->
        <div class="action-toolbar">
          <div class="action-group">
            <el-button-group>
              <el-tooltip content="新增" v-if="isAuth('xiqu', '新增')">
                <el-button
                  type="success"
                  icon="el-icon-plus"
                  class="modern-action-btn"
                  @click="addOrUpdateHandler()"
                  >新增</el-button
                >
              </el-tooltip>

              <el-tooltip content="删除" v-if="isAuth('xiqu', '删除')">
                <el-button
                  type="danger"
                  icon="el-icon-delete"
                  class="modern-action-btn"
                  :disabled="dataListSelections.length <= 0"
                  @click="deleteHandler()"
                  >删除</el-button
                >
              </el-tooltip>

              <!-- <el-tooltip content="数据报表" v-if="isAuth('xiqu', '报表')">
              <el-button
                type="warning"
                icon="el-icon-data-analysis"
                class="modern-action-btn"
                @click="chartDialog()"
                >数据报表</el-button
              >
            </el-tooltip>

            <el-tooltip content="下载模板" v-if="isAuth('xiqu', '导入导出')">
              <a class="modern-link-btn" :href="templateUrl">
                <el-button
                  type="info"
                  icon="el-icon-download"
                  class="modern-action-btn"
                  >模板下载</el-button
                >
              </a>
            </el-tooltip> -->
              <!-- 
            <el-upload
              v-if="isAuth('xiqu', '导入导出')"
              :action="getActionUrl"
              :show-file-list="false"
              class="inline-upload"
            >
              <el-tooltip content="批量导入">
                <el-button
                  type="primary"
                  icon="el-icon-upload"
                  class="modern-action-btn"
                  >批量导入</el-button
                >
              </el-tooltip>
            </el-upload> -->

              <!-- <el-tooltip content="导出数据" v-if="isAuth('xiqu', '导入导出')">
              <download-excel class="inline-export">
                <el-button
                  type="success"
                  icon="el-icon-download"
                  class="modern-action-btn"
                  >导出数据</el-button
                >
              </download-excel>
            </el-tooltip> -->
            </el-button-group>
          </div>
        </div>
      </div>

      <!-- 数据表格 -->
      <div class="modern-table-wrapper">
        <el-table
          :data="dataList"
          class="modern-data-table"
          v-loading="dataListLoading"
          @selection-change="selectionChangeHandler"
        >
          <!-- 选择列 -->
          <el-table-column
            v-if="contents.tableSelection"
            type="selection"
            width="48"
            align="center"
          ></el-table-column>

          <!-- 数据列 -->
          <el-table-column
            label="索引"
            v-if="contents.tableIndex"
            type="index"
            width="180"
            align="center"
          >
            <template slot-scope="scope">
              <span class="index-badge">{{ scope.$index + 1 }}</span>
            </template>
          </el-table-column>

          <el-table-column prop="xiquName" label="知识名称" width="180">
            <template slot-scope="scope">
              <div class="title-cell">
                <i class="el-icon-notebook-1"></i>
                <span class="text-ellipsis">{{ scope.row.xiquName }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="xiquUuidNumber" label="知识编号" width="180">
            <template slot-scope="scope">
              <el-tag type="info" effect="dark">
                {{ scope.row.xiquUuidNumber }}
              </el-tag>
            </template>
          </el-table-column>

          <el-table-column prop="xiquPhoto" label="展示图片" align="center">
            <template slot-scope="scope">
              <div class="image-preview">
                <img
                  v-if="scope.row.xiquPhoto"
                  :src="$base.url + scope.row.xiquPhoto"
                  class="table-image"
                />
                <span v-else class="image-placeholder">暂无图片</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="xiquAddress" label="发源地" width="160">
            <template slot-scope="scope">
              <div class="location-cell">
                <i class="el-icon-location-outline"></i>
                {{ scope.row.xiquAddress }}
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="xiquFile" label="相关文件" width="120">
            <template slot-scope="scope">
              <el-button
                v-if="scope.row.xiquFile"
                type="text"
                icon="el-icon-document"
                @click="downloadFile(scope.row.xiquFile)"
                >下载</el-button
              >
              <span v-else>无文件</span>
            </template>
          </el-table-column>

          <!-- <el-table-column prop="xiquMusic" label="音频" width="180">
            <template slot-scope="scope">
              <div class="audio-player" v-if="scope.row.xiquMusic">
                <audio :src="$base.url + scope.row.xiquMusic" controls>
                  <source type="audio/mpeg" />
                </audio>
              </div>
              <span v-else>无音频</span>
            </template>
          </el-table-column> -->

          <!-- <el-table-column prop="xiquVideo" label="视频" width="160">
            <template slot-scope="scope">
              <div class="video-preview" v-if="scope.row.xiquVideo">
                <video
                  :src="$base.url + scope.row.xiquVideo"
                  poster="/static/video-poster.png"
                ></video>
              </div>
              <span v-else>无视频</span>
            </template>
          </el-table-column> -->

          <el-table-column prop="xiquTypes" label="知识类型" width="140">
            <template slot-scope="scope">
              <el-tag type="warning">{{ scope.row.xiquValue }}</el-tag>
            </template>
          </el-table-column>

          <!-- <el-table-column prop="shangxiaTypes" label="状态" width="100">
            <template slot-scope="scope">
              <el-tag
                :type="scope.row.shangxiaTypes == 1 ? 'success' : 'danger'"
                effect="light"
              >
                {{ scope.row.shangxiaValue }}
              </el-tag>
            </template>
          </el-table-column> -->

          <!-- 操作列 -->
          <el-table-column
            label="操作"
            width="200"
            fixed="right"
            align="center"
          >
            <template slot-scope="scope">
              <div class="table-actions">
                <el-tooltip content="详情" v-if="isAuth('xiqu', '查看')">
                  <el-button
                    type="text"
                    icon="el-icon-view"
                    class="action-btn"
                    @click="addOrUpdateHandler(scope.row.id, 'info')"
                  ></el-button>
                </el-tooltip>

                <el-tooltip content="编辑" v-if="isAuth('xiqu', '修改')">
                  <el-button
                    type="text"
                    icon="el-icon-edit"
                    class="action-btn"
                    @click="addOrUpdateHandler(scope.row.id)"
                  ></el-button>
                </el-tooltip>

                <el-tooltip content="删除" v-if="isAuth('xiqu', '删除')">
                  <el-button
                    type="text"
                    icon="el-icon-delete"
                    class="action-btn"
                    @click="deleteHandler(scope.row.id)"
                  ></el-button>
                </el-tooltip>

                <el-tooltip
                  :content="scope.row.shangxiaTypes == 1 ? '下架' : '上架'"
                >
                  <el-button
                    type="text"
                    :icon="
                      scope.row.shangxiaTypes == 1
                        ? 'el-icon-bottom'
                        : 'el-icon-top'
                    "
                    :class="[
                      'action-btn',
                      scope.row.shangxiaTypes == 1 ? 'danger' : 'success',
                    ]"
                    @click="shangxia(scope.row.id, scope.row.shangxiaTypes)"
                  ></el-button>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>

        <!-- 分页 -->
        <div class="modern-pagination">
          <el-pagination
            background
            :page-sizes="[10, 20, 50, 100]"
            :page-size="Number(contents.pageEachNum)"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalPage"
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
          ></el-pagination>
        </div>
      </div>
    </div>
    <!-- 添加/修改页面  将父组件的search方法传递给子组件-->
    <add-or-update
      v-if="addOrUpdateFlag"
      :parent="this"
      ref="addOrUpdate"
    ></add-or-update>

    <el-dialog
      title="打印"
      :visible.sync="printVisiable"
      width="500px"
      class="modern-dialog"
    >
      <el-form ref="printContent" :model="printFrom" label-width="auto">
        <el-form-item label="发件人">
          <div style="display: flex">
            <el-input v-model="printFrom.kuaidiFajianName" disabled></el-input>
            :
            <el-input
              v-model="printFrom.kuaidiFajianShoujihao"
              disabled
            ></el-input>
          </div>
        </el-form-item>
        <el-form-item label="发件人地址">
          <el-input v-model="printFrom.kuaidiFajianAddress" disabled></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="printContent()" icon="el-icon-printer" type="success"
          >打印</el-button
        >
        <el-button @click="printVisiable = false">关闭</el-button>
      </span>
    </el-dialog>

    <!-- <el-dialog
      title="统计报表"
      :visible.sync="chartVisiable"
      width="80%"
      class="modern-dialog"
    >
      <div id="statistic" style="width: 100%; height: 600px"></div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="chartVisiable = false">关闭</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>
<script>
import AddOrUpdate from "./add-or-update";
import styleJs from "../../../utils/style.js";
import utilsJs, {
  getYearFormat,
  getMonthFormat,
  getDateFormat,
  getDatetimeFormat,
} from "../../../utils/utils.js";

export default {
  data() {
    return {
      //打印开始
      printFrom: {
        name1: "",
      },
      printVisiable: false,
      //打印结束
      searchForm: {
        key: "",
      },
      sessionTable: "", //登录账户所在表名
      role: "", //权限
      userId: "", //当前登录人的id
      //级联表下拉框搜索条件
      //当前表下拉框搜索条件
      xiquTypesSelectSearch: [],
      form: {
        id: null,
        xiquName: null,
        xiquUuidNumber: null,
        xiquPhoto: null,
        xiquAddress: null,
        xiquFile: null,
        xiquMusic: null,
        xiquVideo: null,
        xiquTypes: null,
        zanNumber: null,
        caiNumber: null,
        xiquClicknum: null,
        xiquContent: null,
        shangxiaTypes: null,
        xiquDelete: null,
        insertTime: null,
        createTime: null,
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      showFlag: true,
      sfshVisiable: false,
      shForm: {},
      chartVisiable: false,
      echartsDate: new Date(), //echarts的时间查询字段
      addOrUpdateFlag: false,
      contents: null,
      layouts: "",

      //导出excel
      json_fields: {
        //级联表字段
        //本表字段
        中医药文化知识名称: "xiquName",
        中医药文化知识编号: "xiquUuidNumber",
        中医药文化知识照片: "xiquPhoto",
        发源地: "xiquAddress",
        中医药文化知识文件: "xiquFile",
        中医药文化知识音频: "xiquMusic",
        中医药文化知识视频: "xiquVideo",
        中医药文化知识类型: "xiquValue",
        赞: "zanNumber",
        踩: "caiNumber",
        中医药文化知识热度: "xiquClicknum",
        是否上架: "shangxiaValue",
        录入时间: "insertTime",
      },
    };
  },
  created() {
    this.contents = styleJs.listStyle();
    this.init();
    this.getDataList();
    this.contentStyleChange();
  },
  mounted() {
    //获取当前登录用户的信息
    this.sessionTable = this.$storage.get("sessionTable");
    this.role = this.$storage.get("role");
    this.userId = this.$storage.get("userId");
  },
  filters: {
    htmlfilter: function (val) {
      return val.replace(/<[^>]*>/g).replace(/undefined/g, "");
    },
  },
  components: {
    AddOrUpdate,
  },
  computed: {
    getActionUrl: function () {
      return `/` + this.$base.name + `/file/upload`;
    },
  },
  methods: {
    chartDialog() {
      let _this = this;
      //饼状图
      _this.chartVisiable = true;
      this.$nextTick(() => {
        var statistic = this.$echarts.init(
          document.getElementById("statistic"),
          "macarons"
        );
        let params = {
          tableName: "xiqu",
          groupColumn: "xiqu_types",
        };
        this.$http({
          url: "newSelectGroupCount", //pieSum pieCount
          method: "get",
          params: params,
        }).then(({ data }) => {
          if (data && data.code === 0) {
            let res = data.data;
            let xAxis = [];
            let yAxis = [];
            let pArray = [];
            var option = {};
            for (let i = 0; i < res.length; i++) {
              xAxis.push(res[i].name);
              yAxis.push(res[i].value);
              pArray.push({
                value: res[i].value,
                name: res[i].name,
              });
              option = {
                title: {
                  text: "中医药文化知识类型统计报表",
                  left: "center",
                },
                tooltip: {
                  trigger: "item",
                  formatter: "{b} : {c} ({d}%)",
                },
                legend: {
                  orient: "vertical",
                  left: "left",
                },
                series: [
                  {
                    type: "pie",
                    radius: "55%",
                    center: ["50%", "60%"],
                    data: pArray,
                    emphasis: {
                      itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: "rgba(0, 0, 0, 0.5)",
                      },
                    },
                  },
                ],
              };
            }
            statistic.setOption(option, true);
            window.onresize = function () {
              statistic.resize();
            };
          }
        });
      });
    },
    contentStyleChange() {
      this.contentSearchStyleChange();
      this.contentBtnAdAllStyleChange();
      this.contentSearchBtnStyleChange();
      this.contentTableBtnStyleChange();
      this.contentPageStyleChange();
    },
    contentSearchStyleChange() {
      this.$nextTick(() => {
        document
          .querySelectorAll(".form-content .slt .el-input__inner")
          .forEach((el) => {
            let textAlign = "left";
            if (this.contents.inputFontPosition == 2) textAlign = "center";
            if (this.contents.inputFontPosition == 3) textAlign = "right";
            el.style.textAlign = textAlign;
            el.style.height = this.contents.inputHeight;
            el.style.lineHeight = this.contents.inputHeight;
            el.style.color = this.contents.inputFontColor;
            el.style.fontSize = this.contents.inputFontSize;
            el.style.borderWidth = this.contents.inputBorderWidth;
            el.style.borderStyle = this.contents.inputBorderStyle;
            el.style.borderColor = this.contents.inputBorderColor;
            el.style.borderRadius = this.contents.inputBorderRadius;
            el.style.backgroundColor = this.contents.inputBgColor;
          });
        if (this.contents.inputTitle) {
          document
            .querySelectorAll(".form-content .slt .el-form-item__label")
            .forEach((el) => {
              el.style.color = this.contents.inputTitleColor;
              el.style.fontSize = this.contents.inputTitleSize;
              el.style.lineHeight = this.contents.inputHeight;
            });
        }
        setTimeout(() => {
          document
            .querySelectorAll(".form-content .slt .el-input__prefix")
            .forEach((el) => {
              el.style.color = this.contents.inputIconColor;
              el.style.lineHeight = this.contents.inputHeight;
            });
          document
            .querySelectorAll(".form-content .slt .el-input__suffix")
            .forEach((el) => {
              el.style.color = this.contents.inputIconColor;
              el.style.lineHeight = this.contents.inputHeight;
            });
          document
            .querySelectorAll(".form-content .slt .el-input__icon")
            .forEach((el) => {
              el.style.lineHeight = this.contents.inputHeight;
            });
        }, 10);
      });
    },
    // 搜索按钮
    contentSearchBtnStyleChange() {
      this.$nextTick(() => {
        document
          .querySelectorAll(".form-content .slt .el-button--success")
          .forEach((el) => {
            el.style.height = this.contents.searchBtnHeight;
            el.style.color = this.contents.searchBtnFontColor;
            el.style.fontSize = this.contents.searchBtnFontSize;
            el.style.borderWidth = this.contents.searchBtnBorderWidth;
            el.style.borderStyle = this.contents.searchBtnBorderStyle;
            el.style.borderColor = this.contents.searchBtnBorderColor;
            el.style.borderRadius = this.contents.searchBtnBorderRadius;
            el.style.backgroundColor = this.contents.searchBtnBgColor;
          });
      });
    },
    // 新增、批量删除
    contentBtnAdAllStyleChange() {
      this.$nextTick(() => {
        document
          .querySelectorAll(".form-content .ad .el-button--success")
          .forEach((el) => {
            el.style.height = this.contents.btnAdAllHeight;
            el.style.color = this.contents.btnAdAllAddFontColor;
            el.style.fontSize = this.contents.btnAdAllFontSize;
            el.style.borderWidth = this.contents.btnAdAllBorderWidth;
            el.style.borderStyle = this.contents.btnAdAllBorderStyle;
            el.style.borderColor = this.contents.btnAdAllBorderColor;
            el.style.borderRadius = this.contents.btnAdAllBorderRadius;
            el.style.backgroundColor = this.contents.btnAdAllAddBgColor;
          });
        document
          .querySelectorAll(".form-content .ad .el-button--danger")
          .forEach((el) => {
            el.style.height = this.contents.btnAdAllHeight;
            el.style.color = this.contents.btnAdAllDelFontColor;
            el.style.fontSize = this.contents.btnAdAllFontSize;
            el.style.borderWidth = this.contents.btnAdAllBorderWidth;
            el.style.borderStyle = this.contents.btnAdAllBorderStyle;
            el.style.borderColor = this.contents.btnAdAllBorderColor;
            el.style.borderRadius = this.contents.btnAdAllBorderRadius;
            el.style.backgroundColor = this.contents.btnAdAllDelBgColor;
          });
        document
          .querySelectorAll(".form-content .ad .el-button--warning")
          .forEach((el) => {
            el.style.height = this.contents.btnAdAllHeight;
            el.style.color = this.contents.btnAdAllWarnFontColor;
            el.style.fontSize = this.contents.btnAdAllFontSize;
            el.style.borderWidth = this.contents.btnAdAllBorderWidth;
            el.style.borderStyle = this.contents.btnAdAllBorderStyle;
            el.style.borderColor = this.contents.btnAdAllBorderColor;
            el.style.borderRadius = this.contents.btnAdAllBorderRadius;
            el.style.backgroundColor = this.contents.btnAdAllWarnBgColor;
          });
      });
    },
    // 表格
    rowStyle({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        if (this.contents.tableStripe) {
          return { color: this.contents.tableStripeFontColor };
        }
      } else {
        return "";
      }
    },
    cellStyle({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        if (this.contents.tableStripe) {
          return { backgroundColor: this.contents.tableStripeBgColor };
        }
      } else {
        return "";
      }
    },
    headerRowStyle({ row, rowIndex }) {
      return { color: this.contents.tableHeaderFontColor };
    },
    headerCellStyle({ row, rowIndex }) {
      return { backgroundColor: this.contents.tableHeaderBgColor };
    },
    // 表格按钮
    contentTableBtnStyleChange() {
      // this.$nextTick(()=>{
      //   setTimeout(()=>{
      //     document.querySelectorAll('.table-content .tables .el-table__body .el-button--success').forEach(el=>{
      //       el.style.height = this.contents.tableBtnHeight
      //       el.style.color = this.contents.tableBtnDetailFontColor
      //       el.style.fontSize = this.contents.tableBtnFontSize
      //       el.style.borderWidth = this.contents.tableBtnBorderWidth
      //       el.style.borderStyle = this.contents.tableBtnBorderStyle
      //       el.style.borderColor = this.contents.tableBtnBorderColor
      //       el.style.borderRadius = this.contents.tableBtnBorderRadius
      //       el.style.backgroundColor = this.contents.tableBtnDetailBgColor
      //     })
      //     document.querySelectorAll('.table-content .tables .el-table__body .el-button--primary').forEach(el=>{
      //       el.style.height = this.contents.tableBtnHeight
      //       el.style.color = this.contents.tableBtnEditFontColor
      //       el.style.fontSize = this.contents.tableBtnFontSize
      //       el.style.borderWidth = this.contents.tableBtnBorderWidth
      //       el.style.borderStyle = this.contents.tableBtnBorderStyle
      //       el.style.borderColor = this.contents.tableBtnBorderColor
      //       el.style.borderRadius = this.contents.tableBtnBorderRadius
      //       el.style.backgroundColor = this.contents.tableBtnEditBgColor
      //     })
      //     document.querySelectorAll('.table-content .tables .el-table__body .el-button--danger').forEach(el=>{
      //       el.style.height = this.contents.tableBtnHeight
      //       el.style.color = this.contents.tableBtnDelFontColor
      //       el.style.fontSize = this.contents.tableBtnFontSize
      //       el.style.borderWidth = this.contents.tableBtnBorderWidth
      //       el.style.borderStyle = this.contents.tableBtnBorderStyle
      //       el.style.borderColor = this.contents.tableBtnBorderColor
      //       el.style.borderRadius = this.contents.tableBtnBorderRadius
      //       el.style.backgroundColor = this.contents.tableBtnDelBgColor
      //     })
      //   }, 50)
      // })
    },
    // 分页
    contentPageStyleChange() {
      let arr = [];
      if (this.contents.pageTotal) arr.push("total");
      if (this.contents.pageSizes) arr.push("sizes");
      if (this.contents.pagePrevNext) {
        arr.push("prev");
        if (this.contents.pagePager) arr.push("pager");
        arr.push("next");
      }
      if (this.contents.pageJumper) arr.push("jumper");
      this.layouts = arr.join();
      this.contents.pageEachNum = 10;
    },

    init() {},
    search() {
      this.pageIndex = 1;
      this.getDataList();
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      let params = {
        page: this.pageIndex,
        limit: this.pageSize,
        sort: "id",
      };

      if (
        this.searchForm.xiquName != "" &&
        this.searchForm.xiquName != undefined
      ) {
        params["xiquName"] = "%" + this.searchForm.xiquName + "%";
      }

      if (
        this.searchForm.xiquTypes != "" &&
        this.searchForm.xiquTypes != undefined
      ) {
        params["xiquTypes"] = this.searchForm.xiquTypes;
      }

      params["xiquDelete"] = 1; // 逻辑删除字段 1 未删除 2 删除

      this.$http({
        url: "xiqu/page",
        method: "get",
        params: params,
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.data.list;
          this.totalPage = data.data.total;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
        this.dataListLoading = false;
      });

      //查询级联表搜索条件所有列表
      //查询当前表搜索条件所有列表
      //填充下拉框选项
      this.$http({
        url: "dictionary/page?dicCode=xiqu_types&page=1&limit=100",
        method: "get",
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.xiquTypesSelectSearch = data.data.list;
        }
      });
    },
    //每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 多选
    selectionChangeHandler(val) {
      this.dataListSelections = val;
    },
    // 添加/修改
    addOrUpdateHandler(id, type) {
      this.showFlag = false;
      this.addOrUpdateFlag = true;
      this.crossAddOrUpdateFlag = false;
      if (type != "info") {
        type = "else";
      }
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id, type);
      });
    },
    // 下载
    download(file) {
      window.open(" ${file} ");
    },
    // 弹出打印模态框
    dayinOpen(item) {
      let _this = this;
      _this.printVisiable = true;
      _this.printFrom = item;
    },
    // 打印内容
    printContent() {
      let _this = this;
      _this.$print(_this.$refs.printContent);
      _this.printVisiable = false;
    },
    // 删除
    deleteHandler(id) {
      var ids = id
        ? [Number(id)]
        : this.dataListSelections.map((item) => {
            return Number(item.id);
          });

      this.$confirm(`确定进行[${id ? "删除" : "批量删除"}]操作?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$http({
          url: "xiqu/delete",
          method: "post",
          data: ids,
        }).then(({ data }) => {
          if (data && data.code === 0) {
            this.$message({
              message: "操作成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.search();
              },
            });
          } else {
            this.$message.error(data.msg);
          }
        });
      });
    },
    // 导入功能上传文件成功后调用导入方法
    xiquUploadSuccess(data) {
      let _this = this;
      _this
        .$http({
          url: "xiqu/batchInsert?fileName=" + data.file,
          method: "get",
        })
        .then(({ data }) => {
          if (data && data.code === 0) {
            _this.$message({
              message: "导入中医药文化知识数据成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                _this.search();
              },
            });
          } else {
            _this.$message.error(data.msg);
          }
        });
    },
    // 导入功能上传文件失败后调用导入方法
    xiquUploadError(data) {
      this.$message.error("上传失败");
    },

    //上下架
    shangxia(id, shangxiaTypes) {
      var msg = "";
      if (shangxiaTypes == 1) {
        shangxiaTypes = 2;
        msg = "下架";
      } else if (shangxiaTypes == 2) {
        shangxiaTypes = 1;
        msg = "上架";
      }
      var shuju = {
        id: id,
        shangxiaTypes: shangxiaTypes,
      };
      this.$confirm(`确定要将它` + msg + `吗?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$http({
          url: "xiqu/update",
          method: "post",
          data: shuju,
        }).then(({ data }) => {
          if (data && data.code === 0) {
            this.$message({
              message: msg + "成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.search();
              },
            });
          } else {
            this.$message.error(data.msg);
          }
        });
      });
    },
    // 文件下载
    downloadFile(url) {
      window.open(this.$base.url + url);
    },

    // 时间格式化
    formatTime(time) {
      return dayjs(time).format("YYYY-MM-DD HH:mm");
    },
    //无用
    wuyong(id) {
      let _this = this;
      _this
        .$confirm(`确定    操作?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
        .then(() => {
          _this
            .$http({
              url: "xiqu/update",
              method: "post",
              data: {
                id: id,
                //                            xiquTypes:xiquTypes,
              },
            })
            .then(({ data }) => {
              if (data && data.code === 0) {
                _this.$message({
                  message: "操作成功",
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    _this.search();
                  },
                });
              } else {
                _this.$message.error(data.msg);
              }
            });
        });
    },
  },
};
</script>
<style scoped>
/* 新增中医药主题配色 */
.modern-list-container {
  --primary-color: #3a8e5c; /* 青绿色 */
  --secondary-color: #d4b266; /* 金色 */
  --success-color: #67c23a;
  --warning-color: #e6a23c;
  --danger-color: #f56c6c;
  --info-color: #909399;
  --border-color: #ebeef5;
  --bg-base: #f5f7fa;
  --radius-md: 8px;
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.modern-list-content {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* 搜索栏优化 */
.modern-search-input::v-deep .el-input__inner {
  height: 40px;
  border-radius: 20px;
  padding-left: 40px;
  border: 1px solid var(--primary-color);
}

.modern-select::v-deep .el-input__inner {
  border-radius: 20px;
  padding-left: 15px;
}
.modern-search-panel {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}
.search-group {
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: center;
  width: 90vw;
}
.action-group {
  width: 90vw;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.action-toolbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}
.modern-input {
  width: 250px;
}
.modern-input::v-deep .el-input__inner {
  border-radius: 20px;
  /* padding-left: 15px; */
}
/* 多媒体内容展示 */
.image-preview {
  margin: auto;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-base);
}

.table-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.audio-player audio {
  width: 160px;
  height: 40px;
}

.video-preview video {
  width: 120px;
  height: 80px;
  border-radius: 4px;
  object-fit: cover;
}

/* 状态标签 */
.el-tag--success {
  background-color: rgba(58, 142, 92, 0.1);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* 操作按钮组 */
.table-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.modern-data-table::v-deep {
  --el-table-header-background-color: rgba(245, 247, 250, 0.9);
  --el-table-border-color: var(--border-color);
  /* color: 333; */
}

.action-btn {
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.action-btn.success:hover {
  color: var(--primary-color);
  background: rgba(58, 142, 92, 0.1);
}

.action-btn.danger:hover {
  color: var(--danger-color);
  background: rgba(245, 108, 108, 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .modern-toolbar {
    flex-direction: column;
    gap: 12px;
  }

  .search-group {
    flex-wrap: wrap;
  }

  .modern-search-input,
  .modern-select {
    width: 100%;
  }

  .table-actions {
    flex-wrap: wrap;
  }

  .video-preview video {
    width: 80px;
    height: 60px;
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modern-list-content {
  animation: fadeIn 0.4s ease;
}
</style>
